package com.woniuxy.config;

import io.minio.MinioClient;
import io.minio.errors.InvalidEndpointException;
import io.minio.errors.InvalidPortException;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@ConfigurationProperties(prefix = "minio")
@Configuration
@Data
public class MinioConfig {
    //应该和yml中的配置保持一致
    private String endpoint;
    private String accessKey;
    private String accessSecrt;
    private String bucketName;


    @Bean
    public MinioClient minioClient(){
        MinioClient minioClient = null;
        try {
            minioClient = new MinioClient(endpoint,accessKey,accessSecrt);
        } catch (InvalidEndpointException e) {
            e.printStackTrace();
        } catch (InvalidPortException e) {
            e.printStackTrace();
        }
        return  minioClient;

    }
}
